import { Component, OnInit } from '@angular/core';
import { SFSchema, SFUISchema } from '@delon/form';
import { _HttpClient } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { SupplyManagementService } from '../../services/supply-management.service';

@Component({
  selector: 'app-supply-management-update-external-sn',
  templateUrl: './update-external-sn.component.html',
})
export class SupplyManagementUpdateExternalSnComponent implements OnInit {
  record: any = {};
  orderObject: any;
  schema: SFSchema = {
    properties: {
      owner: {
        type: 'string',
        maxLength: 30,
        title: '',
        ui: {
          placeholder: '不超过30位'
        }
      },
    },
    required: ['owner'],
  };
  ui: SFUISchema = {
    '*': {
      spanControl: 24
    },
  };

  constructor(
    private modal: NzModalRef,
    private msgSrv: NzMessageService,
    public service: SupplyManagementService
  ) { }

  ngOnInit(): void {

  }

  save(value: any): void {
    const { id, sn } = value;
    this.service.request(`/user/${this.record.id}`, { id, sn }).subscribe(res => {
      this.msgSrv.success('保存成功');
      this.modal.close(true);
    });
  }

  close(): void {
    this.modal.destroy();
  }
}
